package com.ruoyi.web.controller.disasterAssessment;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.disasterassessment.domain.AlarmWarnPrediction;
import com.ruoyi.disasterassessment.service.IAlarmWarnPredictionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预警预测模拟数据Controller
 *
 * @author hcc
 * @date 2023-12-20
 */
@Api("预警预测模拟数据")
@RestController
@RequestMapping("/disasterassessment/prediction")
public class AlarmWarnPredictionController extends BaseController
{
    @Autowired
    private IAlarmWarnPredictionService alarmWarnPredictionService;

    /**
     * 查询预警预测模拟数据列表
     */
    @ApiOperation("查询预警预测模拟数据列表")
    @PreAuthorize("@ss.hasPermi('disasterassessment:prediction:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlarmWarnPrediction alarmWarnPrediction)
    {
        startPage();
        List<AlarmWarnPrediction> list = alarmWarnPredictionService.selectAlarmWarnPredictionList(alarmWarnPrediction);
        return getDataTable(list);
    }

    /**
     * 导出预警预测模拟数据列表
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:prediction:export')")
    @Log(title = "预警预测模拟数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlarmWarnPrediction alarmWarnPrediction)
    {
        List<AlarmWarnPrediction> list = alarmWarnPredictionService.selectAlarmWarnPredictionList(alarmWarnPrediction);
        ExcelUtil<AlarmWarnPrediction> util = new ExcelUtil<AlarmWarnPrediction>(AlarmWarnPrediction.class);
        util.exportExcel(response, list, "预警预测模拟数据数据");
    }

    /**
     * 获取预警预测模拟数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:prediction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(alarmWarnPredictionService.selectAlarmWarnPredictionById(id));
    }

    /**
     * 新增预警预测模拟数据
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:prediction:add')")
    @Log(title = "预警预测模拟数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlarmWarnPrediction alarmWarnPrediction)
    {
        return toAjax(alarmWarnPredictionService.insertAlarmWarnPrediction(alarmWarnPrediction));
    }

    /**
     * 修改预警预测模拟数据
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:prediction:edit')")
    @Log(title = "预警预测模拟数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlarmWarnPrediction alarmWarnPrediction)
    {
        return toAjax(alarmWarnPredictionService.updateAlarmWarnPrediction(alarmWarnPrediction));
    }

    /**
     * 删除预警预测模拟数据
     */
    @PreAuthorize("@ss.hasPermi('disasterassessment:prediction:remove')")
    @Log(title = "预警预测模拟数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(alarmWarnPredictionService.deleteAlarmWarnPredictionByIds(ids));
    }
}
